def solve(n,k):
    lst=list(range(1,n+1))
    while(len(lst)>=k): 
        lst=lst[k:]+lst[:k-1]
        print(lst)
    while(len(lst)>1):
        r=k%(len(lst))-1
        lst=lst[:r]+lst[r+1:]
    return lst[0]

print(solve(10,3))
    
